<template>
  <div class="header-container">
    <div class="cn-left flex-box" >
      <el-icon class="icon" :size="20" @click="controlisclose"><Fold /></el-icon>
    </div>
    <div class="cn-right">
      <el-dropdown :hide-on-click="false">
        <span class="el-dropdown-link flex-box">
          <el-avatar
            src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
          />
          <p class="username">admin</p>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>退出登入</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script setup>
import { useStore } from 'vuex'
//拿到store实例
const store = useStore()
const controlisclose = () => {
    store.commit('controlisclose')
    //访问vuex数据
    // console.log(store.state.menu.isclose);
}
</script>

<style lang="less" scoped>
.flex-box {
  display: flex;
  align-items: center;
}
.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  background-color: #fff;
  padding-right: 25px;
  .cn-left {
    height: 100%;
    display: flex;
    .icon {
      width: 45px;
      height: 100%;
    }
    .icon:hover {
      background-color: #f5f5f5;
      cursor: pointer;
    }
  }
  .cn-right{
    .username{
        margin-left: 10px;
    }
  }
}
</style>
